package com.ruoyi.supplier_zz.controller;

import java.util.List;
import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.ModelMap;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.supplier_zz.domain.SupplierZz;
import com.ruoyi.supplier_zz.service.ISupplierZzService;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 供应商信息管理系统Controller
 * 
 * @author zlw
 * @date 2025-06-16
 */
@Controller
@RequestMapping("/supplier_zz/zz")
public class SupplierZzController extends BaseController
{
    private String prefix = "supplier_zz/zz";

    @Autowired
    private ISupplierZzService supplierZzService;

    @RequiresPermissions("supplier_zz:zz:view")
    @GetMapping()
    public String zz()
    {
        return prefix + "/zz";
    }

    /**
     * 查询供应商信息管理系统列表
     */
    @RequiresPermissions("supplier_zz:zz:list")
    @PostMapping("/list")
    @ResponseBody
    public TableDataInfo list(SupplierZz supplierZz)
    {
        startPage();
        List<SupplierZz> list = supplierZzService.selectSupplierZzList(supplierZz);
        return getDataTable(list);
    }

    /**
     * 导出供应商信息管理系统列表
     */
    @RequiresPermissions("supplier_zz:zz:export")
    @Log(title = "供应商信息管理系统", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    @ResponseBody
    public AjaxResult export(SupplierZz supplierZz)
    {
        List<SupplierZz> list = supplierZzService.selectSupplierZzList(supplierZz);
        ExcelUtil<SupplierZz> util = new ExcelUtil<SupplierZz>(SupplierZz.class);
        return util.exportExcel(list, "供应商信息管理系统数据");
    }

    /**
     * 新增供应商信息管理系统
     */
    @RequiresPermissions("supplier_zz:zz:add")
    @GetMapping("/add")
    public String add()
    {
        return prefix + "/add";
    }

    /**
     * 新增保存供应商信息管理系统
     */
    @RequiresPermissions("supplier_zz:zz:add")
    @Log(title = "供应商信息管理系统", businessType = BusinessType.INSERT)
    @PostMapping("/add")
    @ResponseBody
    public AjaxResult addSave(SupplierZz supplierZz)
    {
        return toAjax(supplierZzService.insertSupplierZz(supplierZz));
    }

    /**
     * 修改供应商信息管理系统
     */
    @RequiresPermissions("supplier_zz:zz:edit")
    @GetMapping("/edit/{supplierId}")
    public String edit(@PathVariable("supplierId") Long supplierId, ModelMap mmap)
    {
        SupplierZz supplierZz = supplierZzService.selectSupplierZzBySupplierId(supplierId);
        mmap.put("supplierZz", supplierZz);
        return prefix + "/edit";
    }

    /**
     * 修改保存供应商信息管理系统
     */
    @RequiresPermissions("supplier_zz:zz:edit")
    @Log(title = "供应商信息管理系统", businessType = BusinessType.UPDATE)
    @PostMapping("/edit")
    @ResponseBody
    public AjaxResult editSave(SupplierZz supplierZz)
    {
        return toAjax(supplierZzService.updateSupplierZz(supplierZz));
    }

    /**
     * 删除供应商信息管理系统
     */
    @RequiresPermissions("supplier_zz:zz:remove")
    @Log(title = "供应商信息管理系统", businessType = BusinessType.DELETE)
    @PostMapping( "/remove")
    @ResponseBody
    public AjaxResult remove(String ids)
    {
        return toAjax(supplierZzService.deleteSupplierZzBySupplierIds(ids));
    }
}
